<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>登录</title>
    <link rel="stylesheet" href="<?php echo _APP_URL_;?>/library/layui/css/layui.css">
    <style>
/** 登录页面样式 */
body { background-color: #f0f2f5; background-size: cover;background-image:url(<?php echo _MODULE_URL_;?>/view/default/static/image/bg_cover.jpg);}

.login-wrapper, body, html { height: 100%;}
.login-wrapper { overflow: auto;position: absolute;top: 0; bottom: 0;left: 0;right: 0;}
.login-body {padding: 10px 10px 40px 10px;}
.login-body > .layui-card { max-width: 360px;margin: 0 auto;box-shadow: 0 0 20px #aaa;}
.login-body .layui-card-header { font-weight: 700; font-size: 15px;}
.login-body .layui-form-pane .layui-form-label { width: 48px; overflow: visible;}
.login-body .layui-form-pane .layui-input-block { margin-left: 48px;}
.login-body .login-captcha { width: 100%;height: 38px; cursor: pointer; border: 1px solid #e6e6e6;  border-radius: 2px;box-sizing: border-box;}

/** 头部样式 */
.login-header { font-family: Myriad Pro, Helvetica Neue, Arial, Helvetica, sans-serif; font-size: 20px; font-weight: 600; color: rgba(255, 255, 255, 0.85) !important; color: rgba(0, 0, 0, .85) !important; padding: 10px;}
.login-header img { height: 40px;}

/** 底部样式 */
.login-footer { text-align: center; line-height: 30px; color: rgba(0, 0, 0, 0.7) !important; padding-bottom: 20px;}
.login-footer span { padding: 0 5px;}
.login-footer a { padding: 0 5px;    color: rgba(0, 0, 0, 0.7) !important;}
.login-footer a:hover {  color: rgba(0, 0, 0, 0.4) !important;}

/** 移动设备样式 */
@media screen and (min-height: 590px) {
    .login-footer { position: absolute; bottom: 0;  width: 100%;  }
}

@media screen and (min-height: 670px) {
    .login-body { padding: 110px 10px 40px 10px; }
}

/** 辅助样式 */
.layui-link { color: #029789 !important;}
.layui-link:hover { opacity: .8;}
.pull-right { float: right;}
.inline-block { display: inline-block;}

</style>
    <script>
        if (window != top) {
            top.location.replace(location.href);
        }
    </script>
</head>
<body>
<div class="login-wrapper">
    <div class="login-header">
        <br><br><br>
    </div>
    <div class="login-body">
        <div class="layui-card">
            <div class="layui-card-header">
                <i class="layui-icon layui-icon-console"></i>&nbsp;&nbsp;用户登录
            </div>
            <form class="layui-card-body layui-form layui-form-pane">
                <div class="layui-form-item">
                    <label class="layui-form-label"><i class="layui-icon layui-icon-username"></i></label>
                    <div class="layui-input-block">
                        <input name="username" type="text" placeholder="账号" class="layui-input"
                               lay-verType="tips" lay-verify="required" autocomplete="off" required autofocus />
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"><i class="layui-icon layui-icon-password"></i></label>
                    <div class="layui-input-block">
                        <input name="password" type="password" placeholder="密码" class="layui-input"
                               lay-verType="tips" lay-verify="required" required/>
                    </div>
                </div>

                <div class="layui-form-item" <?php echo (isset( $GLOBALS['config']['应用入口']['login_captcha'] ) && $GLOBALS['config']['应用入口']['login_captcha']==='启用')?'':' hidden ';?>   >
                    <label class="layui-form-label"><i class="layui-icon layui-icon-vercode"></i></label>
                    <div class="layui-input-block">
                        <div class="layui-row inline-block">
                            <div class="layui-col-xs7">
                                <input name="code" type="text" placeholder="验证码" class="layui-input"
                                       autocomplete="off" lay-verType="tips"  <?php echo (isset( $GLOBALS['config']['应用入口']['login_captcha'] ) && $GLOBALS['config']['应用入口']['login_captcha']==='启用')?'lay-verify="required" required':' ';?>
                                    />
                            </div>
                            <div class="layui-col-xs5" style="padding-left: 6px;">
                                <img class="login-captcha" src="<?php echo url('platform/index/captcha'); ?>">
                            </div>
                        </div>
                    </div>
                </div>
                <!-- 
                <div class="layui-form-item">
                    <a href="javascript:;" class="layui-link">帐号注册</a>
                    <a href="javascript:;" class="layui-link pull-right">忘记密码？</a>
                </div> -->
                <div class="layui-form-item">
                    <button lay-filter="login-submit" class="layui-btn layui-btn-fluid" lay-submit>登 录</button>
                </div>
            </form>
        </div>
    </div>

    <!-- <div class="login-footer">
        <p>© PHPwork 版权所有</p>
        <p>
            <span><a href="" target="_blank">获取授权</a></span>
            <span><a href="https://www.kancloud.cn/ruanjie/deep_phpwork" target="_blank">开发文档</a></span>
        </p>
    </div> -->
</div>

<!-- js部分 -->
<script src="<?php echo _APP_URL_;?>/library/layui/layui.js"></script>
<script>
layui.use(['layer', 'form'], function () {
    var $ = layui.jquery;
    var layer = layui.layer;
    var form = layui.form;

    // 表单提交
    form.on('submit(login-submit)', function (obj) {
        //console.log(obj.field);
        $.ajax({
            url:"<?php echo url('platform/index/api_login_check'); ?>",
            data:{'username':obj.field.username,'password':obj.field.password,'code':obj.field.code},
            type:"POST",
            dataType:"json",
            success:function(data){
                if(data.code==200){
                    $('.login-wrapper').fadeOut(1500);
                    layer.msg(data.message, { icon: 1, time: 1500,shade: 0.3 ,anim: 1}, function () {                            
						location.replace( data.data.url );
                    });
                }else{
                    $('input[name=code]').val('');
                    $('.login-captcha').attr('src',  '<?php echo url('platform/index/captcha'); ?>' + '&t=' + (new Date).getTime() );
                    layer.msg(data.message, { icon: 2, time: 1500,shade: 0.3 ,anim: 1}, function () {});
                }
            },
            error:function(data){
                layer.msg(data.message, { icon: 2, time: 1500,shade: 0.3 ,anim: 1}, function () {});
            }
        });
        return false;
    });

    // 图形验证码
    $('.login-captcha').click(function () {
        this.src = "<?php echo url('platform/index/captcha'); ?>" + '&t=' + (new Date).getTime();
    });
});
</script>
</body>
</html>